<?php

namespace app\adminapi\controller\v1\office;

use app\adminapi\controller\AuthController;
use app\services\office\OfficeClassService;
use think\facade\App;

class OfficeClass extends AuthController
{
    public function __construct(App $app, OfficeClassService $service)
    {
        parent::__construct($app);
        $this->services = $service;
    }

    public function index()
    {
        $where = $this->request->postMore([
            ['page', 1],
            ['pageSize', 20],
            ['website_id', $this->website],
            ['title', ''],
            ['class_code', ''],
            ['garde', ''],
            ['major_id', ''],
            ['class_type', ''],
        ]);
        return app()->make('json')->successful($this->services->index($where));
    }

    public function create()
    {
        $where = $this->request->postMore([
            ['page', 1],
            ['pageSize', 20],
            ['website_id', $this->website],
            ['major_id', ''],
            ['class_img', ''],
            ['class_code', ''],
            ['garde', ''],
            ['title', ''],
            ['is_drat', ''],
            ['is_speed', ''],
            ['progress', ''],
            ['class_type', ''],
            ['score', ''],
            ['start_time', ''],
            ['end_time', ''],
        ]);
        return app()->make('json')->successful($this->services->create($where));
    }

    public function update()
    {
        $where = $this->request->postMore([
            ['page', 1],
            ['id', ''],
            ['pageSize', 20],
            ['major_id', ''],
            ['class_code', ''],
            ['garde', ''],
            ['title', ''],
            ['class_img', ''],
            ['is_drat', ''],
            ['is_speed', ''],
            ['progress', ''],
            ['class_type', ''],
            ['score', ''],
            ['start_time', ''],
            ['end_time', ''],
        ]);
        return app()->make('json')->successful($this->services->update($where));
    }

    public function delete()
    {
        $where = $this->request->postMore([
            ['id', 1],
        ]);
        return app()->make('json')->successful($this->services->delete($where));
    }


    public function getList()
    {
        $where = $this->request->postMore([
            ['title', ''],
            ['page', 1],
            ['pageSize', 20],
            ['website_id', $this->website],
        ]);
        return app()->make('json')->successful($this->services->getList($where));
    }

}